package L01;
//wait  和  notify(通知)
//wait  的执行  先解锁，进入阻塞，等待其他程序运行后加锁运行
//该两个方法是Object方法  类方法


public class T19 {
    public static void main (String[] args) {

        Object object=new Object ();
        Thread t1=new Thread (()->{
            synchronized (object){
                System.out.println ("wait之前");
                try {
                    object.wait (3000);//超时时间
                } catch (InterruptedException e) {
                    throw new RuntimeException (e);
                }
                System.out.println ("wait之后");
            }
        });

        Thread t2=new Thread (()->{
           synchronized (object){
               try {
                   Thread.sleep (1000);
               } catch (InterruptedException e) {
                   throw new RuntimeException (e);
               }
               System.out.println ("进行通知");


               object.notify ();
           }
        });

        t1.start ();
        t2.start ();

    }


}
